<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<button>按钮</button>
<button>按钮</button>
<button>按钮</button>
<button>按钮</button>
<button>按钮</button>
<!--<script type="text/javascript">-->
<!--    window.onload = function () {-->
<!--        var buttons = document.getElementsByTagName('button');-->
<!--        for (var i = 0; i < buttons.length; i++) {-->
<!--            buttons[i].onclick = function () {-->
<!--                alert('按钮被点击！');-->
<!--            }-->
<!--        }-->
<!--    }-->
<!--</script>-->

<script type="text/javascript" src="https://libs.baidu.com/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript">
    $(function () {
        console.log(document.getElementsByTagName('button'));
        console.log($('button'));
        $('button').click(function () {
            alert('按钮被点击！');
        });
    })
</script>
</body>
</html>